function myAjax(url,type='get',data='',callback = function(){}){
    let xhr;
    if(XMLHttpRequest){
        xhr = new XMLHttpRequest();
    }else{
        xhr = new ActiveXObject('Microsoft.XMLHTTP');
    }

    if(type === 'get'){
        xhr.open('get',`${url}?${data}`);
    }else if(type === 'post'){
        xhr.open('post',url);
    }

    if(type === 'post'){
        xhr.setRequestHeader( 'content-type' , 'application/x-www-form-urlencoded' );
    }

    if(type === 'get'){
        xhr.send();
    }else if(type === 'post'){
        xhr.send(data);
    }

    xhr.onreadystatechange = function(){
        if(xhr.readyState === 4 && /^2\d{2}$/.test(xhr.status)){
            callback(xhr.responseText);
        }
    }
}